{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Aligning two matrices with the procrustes function\n\nIn this example, we load in some synthetic data, rotate it, and then use the\nprocustes function to get the datasets back in alignment.  The procrustes\nfunction uses linear transformations to project a source matrix into the\nspace of a target matrix.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# Code source: Andrew Heusser\n# License: MIT\n\n# import\nimport hypertools as hyp\nimport numpy as np\nimport scipy\n\n# load example data\ngeo = hyp.load('spiral')\ngeo.plot(title='Before Alignment')\n\n# use procrusted to align the data\nsource, target = geo.get_data()\naligned = [hyp.tools.procrustes(source, target), target]\n\n# after alignment\nhyp.plot(aligned, ['-','--'], title='After alignment')"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.12.4"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}